import Vue from 'vue'
import VueRouter from 'vue-router'


// 导入js文件
const path = require('path')
const files = require.context('./modules', false, /\.js$/)
const modules = []
files.keys().forEach(key => {
  const name = path.basename(key, '.js')
  modules.push(...(files(key).default || files(key)))
})


Vue.use(VueRouter)

// mainPage
const ConstRoutes = [{
    path: '/home',
    name: 'Home',
    component: () => import ('home/Home.vue')
}]

const asyRoutes = [
    ...modules
]

const router = new VueRouter({
    routes: [
        ...ConstRoutes,
        ...asyRoutes
    ]
})
export default router